//============================================================================
// Name        : problem151.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int sum(int * const arr) {
	int result = 0;
	for (int i = 0; i < 4; i++)
		result += arr[i];
	return result;
}

bool stop(int *const arr){
	if(arr[0]== 0 && arr[1]==0 && arr[2]== 0 && arr[3] == 1) return true;
	return false;
}

static float expected = 0;
int recursion(float p, int *size) {
	if(stop(size)) return 0;
	if (sum(size) == 1) {
		expected += p;
	}
	if (size[0] > 0) {
		int next1[] = {size[0]-1, size[1]+1, size[2]+1, size[3]+1};
		recursion(p*size[0]/sum(size), next1);
	}

	if (size[1] > 0) {
		int next2[] = {size[0], size[1]-1, size[2]+1, size[3]+1};
		recursion(p*size[1]/sum(size), next2);
	}

	if (size[2] > 0) {
		int next3[] = {size[0], size[1], size[2]-1, size[3]+1};
		recursion(p*size[2]/sum(size), next3);
	}

	if (size[3] > 0) {
		int next4[] = {size[0], size[1], size[2], size[3]-1};
		recursion(p*size[3]/sum(size), next4);
	}
	return 0;
}
int main() {
	int size[4] = {1, 1, 1, 1};
	float p = 1;
	recursion(p, size);
	cout<<expected<<endl;
	return 0;
}
